<?php

require_once('Zend/Controller/Action.php');

class Cms_Controller_Action extends Zend_Controller_Action
{
	
	const STATUS_INACTIVE = 0;
	const STATUS_ACTIVE = 1;
	const STATUS_PUBLISHED = 10;
	const STATUS_DRAFT = 11;
	const STATUS_SUBMIT = 12;
	const APPLICATION_STATE = 'staging';
	
	protected $CACHE;
	protected $CONFIG;
	protected $LANGUAGE;
	protected $User;
	protected $GLOBAL;
	protected $translate;
	
	private $ErrorMessages;
	
	
	
	public function __construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs = array())
    {
		$this->CONFIG = Zend_Registry::get('config');
    	if(file_exists('../app_mvc/' . $request->getModuleName() . '/lib/config.xml')) {
    		$GLOBAL = new Zend_Config_Xml('../config/config.xml','global', true);
    		$CONFIG = new Zend_Config_Xml('../app_mvc/' . $request->getModuleName() . '/lib/config.xml', $GLOBAL->mode, true);
    		$CONFIG->merge($GLOBAL);
    		$this->CONFIG->merge($CONFIG);
    		Zend_Registry::set('config',$CONFIG);
    	}
		$this->CACHE = Zend_Registry::get('cache');
		$this->LANGUAGE = Zend_Registry::get('language');
		$this->GLOBAL = Zend_Registry::get('global');
		$this->User = new Zend_Session_Namespace('Zend_Auth');
		$this->translate = Zend_Registry::get('Zend_Translate');
		Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
		parent::__construct($request,$response,$invokeArgs);
	}
	
	public function fileName($file_name)
	{
		$randomId=rand(2, 109);
		$file_name = $randomId .'-'. $this->User->UserId.'-'. $file_name;
		
		return $file_name;
	}
	
	private function setErrorMessages($value)
	{
		$this->ErrorMessages[] = $value;
		
	}
	
	public function getErrorMessages()
	{
		return $this->ErrorMessages;
	}
}